function gi(b) {
    var a;
    try {
        a = document.getElementById(b)
    } catch(e1) {
        a = null;
        try {
            a = document.all(b)
        } catch(e2) {
            a = null;
            try {
                a = document.layers[b]
            } catch(e3) {
                a = null
            }
        }
    }
    return (typeof(a) == "object") ? a : console.error("ERR gi " + b)
}

function starts_with(b, a) {
    return b.substr(0, a.length) === a
}

function trim_leading_comments(b) {
    b = b.replace(/^(\s*\/\/[^\n]*\n)+/, "");
    b = b.replace(/^\s+/, "");
    return b
}

function saringPackScript(b) {
    if (gi("packdetect").checked) {
        var a = trim_leading_comments(b);
        try {
            if (starts_with(a.toLowerCase().replace(/ +/g, ""), "eval(function(p,a,c,k")) {
                eval("var unpackedscript = " + a.substring(4) + ";");
                return saringPackScript(unpackedscript)
            } else {
                if (JavascriptObfuscator.detect(a)) {
                    var d = JavascriptObfuscator.unpack(a);
                    if (d !== a) {
                        return saringPackScript(d)
                    }
                }
            }
        } catch(error) {
            console.error("Running saringPackScript " + error)
        }
    }
    return b
}

function okJSpercantik() {
    gi("percantik").disabled = true;
    var b = gi("inout").value.replace(/^\s+/, "");
    var a = gi("tabsize").value;
    var d = " ";
    var f = gi("pnLine").checked;
    if (a == 1) {
        d = "\t"
    }
    if (b && b[0] === "<" && b.substring(0, 4) !== "<!--") {
        gi("inout").value = style_html(b, a, d, 80)
    } else {
        gi("inout").value = JSpercantik(saringPackScript(b), {
            indent_size: a,
            indent_char: d,
            preserve_newlines: f,
            space_after_anon_function: true
        })
    }
    gi("percantik").disabled = false;
    return false
}

function get_var(b) {
    var a = new RegExp("[\\?&]" + b + "=([^&#]*)").exec(window.location.href);
    return a ? a[1] : ""
}

function run_tests() {
    var b = new SanityTest();
    JavascriptObfuscator.run_tests(b);
    return b.results()
}

function SanityTest(m, r) {
    var s = m ||
    function (b) {
        return b
    };
    var r = r || "";
    var t = 0;
    var y = 0;
    var z = [];
    this.test_function = function (b, a) {
        s = b;
        r = a || ""
    };
    this.expect = function (b, a) {
        var d = s(b);
        if ((d === a) || (a instanceof Array && d.join(", ") == a.join(", "))) {
            y += 1
        } else {
            t += 1;
            z.push([r, b, a, d])
        }
    };
    this.results_raw = function () {
        var b = "";
        if (t === 0) {
            if (y === 0) {
                b = "No tests run."
            } else {
                b = "All " + y + " tests passed."
            }
        } else {
            for (var a = 0; a < z.length; a++) {
                var d = z[a];
                if (d[0]) {
                    d[0] = d[0] + " "
                }
                b += "---- " + d[0] + "input -------\n" + this.prettyprint(d[1]) + "\n";
                b += "---- " + d[0] + "expected ----\n" + this.prettyprint(d[2]) + "\n";
                b += "---- " + d[0] + "output ------\n" + this.prettyprint(d[3]) + "\n\n"
            }
            b += t + " tests failed.\n"
        }
        return b
    };
    this.results = function () {
        return this.lazy_escape(this.results_raw())
    };
    this.prettyprint = function (b, a) {
        var d = typeof b;
        switch (d.toLowerCase()) {
        case "string":
            if (a) {
                return "'" + b.replace("'", "\\'") + "'"
            } else {
                return b
            }
        case "number":
            return "" + b;
        case "boolean":
            return b ? "true" : "false";
        case "undefined":
            return "undefined";
        case "object":
            if (b instanceof Array) {
                var f = [];
                var q = 0;
                for (k in b) {
                    if (k == q) {
                        f.push(this.prettyprint(b[k], true));
                        q += 1
                    } else {
                        f.push("\n" + k + ": " + this.prettyprint(b[k], true))
                    }
                }
                return "[" + f.join(", ") + "]"
            } else {
                return "object: " + b
            }
        default:
            return d + ": " + b
        }
    };
    this.lazy_escape = function (b) {
        return b.replace(/</g, "&lt;").replace(/\>/g, "&gt;").replace(/\n/g, "<br />")
    };
    this.log = function () {
        if (window.console) {
            if (console.firebug) {
                console.log.apply(console, Array.prototype.slice.call(arguments))
            } else {
                console.log.call(console, Array.prototype.slice.call(arguments))
            }
        }
    }
}

function JSpercantik(Q, v) {
    var c, j, h, g, n, N, C, i, O, D;
    var R, G, P, e, H, S;
    var w, I, J;
    var E, F, K;
    v = v || {};
    var T = v.indent_size || 4;
    var ba = v.indent_char || " ";
    var bb = typeof v.preserve_newlines === "undefined" ? true : v.preserve_newlines;
    var bc = v.indent_level || 0;
    var bd = v.space_after_anon_function === "undefined" ? false : v.space_after_anon_function;
    K = false;

    function U() {
        while (j.length && (j[j.length - 1] === " " || j[j.length - 1] === D)) {
            j.pop()
        }
    }

    function l(b) {
        b = typeof b === "undefined" ? true : b;
        i.if_line = false;
        U();
        if (!j.length) {
            return
        }
        if (j[j.length - 1] !== "\n" || !b) {
            K = true;
            j.push("\n")
        }
        for (var a = 0; a < E; a += 1) {
            j.push(D)
        }
    }

    function p() {
        var b = " ";
        if (j.length) {
            b = j[j.length - 1]
        }
        if (b !== " " && b !== "\n" && b !== D) {
            j.push(" ")
        }
    }

    function o() {
        K = false;
        j.push(h)
    }

    function L() {
        E += 1
    }

    function M() {
        if (E) {
            E -= 1
        }
    }

    function V() {
        if (j.length && j[j.length - 1] === D) {
            j.pop()
        }
    }

    function be() {
        var b = h.split("\n");
        j.push(b[0]);
        for (var a = 1; a < b.length; a++) {
            l();
            j.push(" ");
            j.push(b[a].replace(/^\s+/, ""))
        }
    }

    function A(b) {
        if (i) {
            O.push(i)
        }
        i = {
            mode: b,
            var_line: false,
            var_line_tainted: false,
            if_line: false,
            in_case: false
        }
    }

    function W(b) {
        return b === "[EXPRESSION]" || b === "[INDENTED-EXPRESSION]" || b === "(EXPRESSION)"
    }

    function X() {
        J = i.mode === "DO_BLOCK";
        i = O.pop()
    }

    function u(b, a) {
        for (var d = 0; d < a.length; d += 1) {
            if (a[d] === b) {
                return true
            }
        }
        return false
    }

    function bf() {
        var b = 0,
            a = 0;
        for (var d = j.length - 1; d >= 0; d--) {
            switch (j[d]) {
            case ":":
                if (b === 0) {
                    a++
                }
                break;
            case "?":
                if (b === 0) {
                    if (a === 0) {
                        return true
                    } else {
                        a--
                    }
                }
                break;
            case "{":
                if (b === 0) {
                    return false
                }
                b--;
                break;
            case "(":
            case "[":
                b--;
                break;
            case ")":
            case "]":
            case "}":
                b++;
                break
            }
        }
    }

    function Y() {
        var b = 0;
        if (e >= c.length) {
            return ["", "grEOF"]
        }
        var a = c.charAt(e);
        e += 1;
        while (u(a, R)) {
            if (e >= c.length) {
                return ["", "grEOF"]
            }
            if (a === "\n") {
                b += 1
            }
            a = c.charAt(e);
            e += 1
        }
        F = false;
        if (bb) {
            if (b > 1) {
                for (var d = 0; d < 2; d += 1) {
                    l(d === 0)
                }
            }
            F = (b === 1)
        }
        if (u(a, G)) {
            if (e < c.length) {
                while (u(c.charAt(e), G)) {
                    a += c.charAt(e);
                    e += 1;
                    if (e === c.length) {
                        break
                    }
                }
            }
            if (e !== c.length && a.match(/^[0-9]+[Ee]$/) && (c.charAt(e) === "-" || c.charAt(e) === "+")) {
                var f = c.charAt(e);
                e += 1;
                var q = Y(e);
                a += f + q[0];
                return [a, "grWORD"]
            }
            if (a === "in") {
                return [a, "grOPERATOR"]
            }
            if (F && g !== "grOPERATOR" && !i.if_line) {
                l()
            }
            return [a, "grWORD"]
        }
        if (a === "(" || a === "[") {
            return [a, "grSTART_EXPR"]
        }
        if (a === ")" || a === "]") {
            return [a, "grEND_EXPR"]
        }
        if (a === "{") {
            return [a, "grSTART_BLOCK"]
        }
        if (a === "}") {
            return [a, "grEND_BLOCK"]
        }
        if (a === ";") {
            return [a, "grSEMICOLON"]
        }
        if (a === "/") {
            var m = "";
            if (c.charAt(e) === "*") {
                e += 1;
                if (e < c.length) {
                    while (! (c.charAt(e) === "*" && c.charAt(e + 1) && c.charAt(e + 1) === "/") && e < c.length) {
                        m += c.charAt(e);
                        e += 1;
                        if (e >= c.length) {
                            break
                        }
                    }
                }
                e += 2;
                return ["/*" + m + "*/", "grBLOCK_COMMENT"]
            }
            if (c.charAt(e) === "/") {
                m = a;
                while (c.charAt(e) !== "\r" && c.charAt(e) !== "\n") {
                    m += c.charAt(e);
                    e += 1;
                    if (e >= c.length) {
                        break
                    }
                }
                e += 1;
                if (F) {
                    l()
                }
                return [m, "grCOMMENT"]
            }
        }
        if (a === "'" || a === "\"" || (a === "/" && ((g === "grWORD" && u(n, ["return", "do"])) || (g === "grSTART_EXPR" || g === "grSTART_BLOCK" || g === "grEND_BLOCK" || g === "grOPERATOR" || g === "grEOF" || g === "grSEMICOLON")))) {
            var r = a;
            var s = false;
            var t = a;
            if (e < c.length) {
                if (r === "/") {
                    var y = false;
                    while (s || y || c.charAt(e) !== r) {
                        t += c.charAt(e);
                        if (!s) {
                            s = c.charAt(e) === "\\";
                            if (c.charAt(e) === "[") {
                                y = true
                            } else {
                                if (c.charAt(e) === "]") {
                                    y = false
                                }
                            }
                        } else {
                            s = false
                        }
                        e += 1;
                        if (e >= c.length) {
                            return [t, "grSTRING"]
                        }
                    }
                } else {
                    while (s || c.charAt(e) !== r) {
                        t += c.charAt(e);
                        if (!s) {
                            s = c.charAt(e) === "\\"
                        } else {
                            s = false
                        }
                        e += 1;
                        if (e >= c.length) {
                            return [t, "grSTRING"]
                        }
                    }
                }
            }
            e += 1;
            t += r;
            if (r === "/") {
                while (e < c.length && u(c.charAt(e), G)) {
                    t += c.charAt(e);
                    e += 1
                }
            }
            return [t, "grSTRING"]
        }
        if (a === "#") {
            var z = "#";
            if (e < c.length && u(c.charAt(e), S)) {
                do {
                    a = c.charAt(e);
                    z += a;
                    e += 1
                } while (e < c.length && a !== "#" && a !== "=");
                if (a === "#") {
                    return [z, "grWORD"]
                } else {
                    return [z, "grOPERATOR"]
                }
            }
        }
        if (a === "<" && c.substring(e - 1, e + 3) === "<!--") {
            e += 3;
            return ["<!--", "grCOMMENT"]
        }
        if (a === "-" && c.substring(e - 1, e + 2) === "-->") {
            e += 2;
            if (F) {
                l()
            }
            return ["-->", "grCOMMENT"]
        }
        if (u(a, P)) {
            while (e < c.length && u(a + c.charAt(e), P)) {
                a += c.charAt(e);
                e += 1;
                if (e >= c.length) {
                    break
                }
            }
            return [a, "grOPERATOR"]
        }
        return [a, "grUNKNOWN"]
    }
    D = "";
    while (T > 0) {
        D += ba;
        T -= 1
    }
    E = bc;
    c = Q;
    C = "";
    g = "grSTART_EXPR";
    n = "";
    N = "";
    j = [];
    J = false;
    R = "\n\r\t ".split("");
    G = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$".split("");
    S = "0123456789".split("");
    P = "+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::".split(" ");
    H = "continue,try,throw,return,var,if,switch,case,default,for,while,break,function".split(",");
    O = [];
    A("BLOCK");
    e = 0;
    while (true) {
        var Z = Y(e);
        h = Z[0];
        I = Z[1];
        if (I === "grEOF") {
            break
        }
        switch (I) {
        case "grSTART_EXPR":
            if (h === "[") {
                if (g === "grWORD" || n === ")") {
                    if (C === "return" || C === "throw") {
                        p()
                    }
                    A("(EXPRESSION)");
                    o();
                    break
                }
                if (i.mode === "[EXPRESSION]" || i.mode === "[INDENTED-EXPRESSION]") {
                    if (N === "]" && n === ",") {
                        L();
                        l();
                        A("[INDENTED-EXPRESSION]")
                    } else {
                        if (n === "[") {
                            L();
                            l();
                            A("[INDENTED-EXPRESSION]")
                        } else {
                            A("[EXPRESSION]")
                        }
                    }
                } else {
                    A("[EXPRESSION]")
                }
            } else {
                A("(EXPRESSION)")
            }
            if (n === ";" || g === "grSTART_BLOCK") {
                l()
            } else {
                if (g === "grEND_EXPR" || g === "grSTART_EXPR") {} else {
                    if (g !== "grWORD" && g !== "grOPERATOR") {
                        p()
                    } else {
                        if (C === "function") {
                            if (bd) {
                                p()
                            }
                        } else {
                            if (u(C, H)) {
                                p()
                            }
                        }
                    }
                }
            }
            o();
            break;
        case "grEND_EXPR":
            if (h === "]" && i.mode === "[INDENTED-EXPRESSION]") {
                M()
            }
            X();
            o();
            break;
        case "grSTART_BLOCK":
            if (C === "do") {
                A("DO_BLOCK")
            } else {
                A("BLOCK")
            }
            if (g !== "grOPERATOR" && g !== "grSTART_EXPR") {
                if (g === "grSTART_BLOCK") {
                    l()
                } else {
                    p()
                }
            }
            o();
            L();
            break;
        case "grEND_BLOCK":
            if (g === "grSTART_BLOCK") {
                if (K) {
                    V()
                } else {
                    U()
                }
                M()
            } else {
                M();
                l()
            }
            o();
            X();
            break;
        case "grWORD":
            if (J) {
                p();
                o();
                p();
                J = false;
                break
            }
            if (h === "function") {
                if (n === ";" || n === "}") {
                    l(false);
                    l(false)
                }
            }
            if (h === "case" || h === "default") {
                if (n === ":") {
                    V()
                } else {
                    M();
                    l();
                    L()
                }
                o();
                i.in_case = true;
                break
            }
            w = "NONE";
            if (g === "grEND_BLOCK") {
                if (!u(h.toLowerCase(), ["else", "catch", "finally"])) {
                    w = "NEWLINE"
                } else {
                    w = "SPACE";
                    p()
                }
            } else {
                if (g === "grSEMICOLON" && (i.mode === "BLOCK" || i.mode === "DO_BLOCK")) {
                    w = "NEWLINE"
                } else {
                    if (g === "grSEMICOLON" && W(i.mode)) {
                        w = "SPACE"
                    } else {
                        if (g === "grSTRING") {
                            w = "NEWLINE"
                        } else {
                            if (g === "grWORD") {
                                w = "SPACE"
                            } else {
                                if (g === "grSTART_BLOCK") {
                                    w = "NEWLINE"
                                } else {
                                    if (g === "grEND_EXPR") {
                                        p();
                                        w = "NEWLINE"
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (g !== "grEND_BLOCK" && u(h.toLowerCase(), ["else", "catch", "finally"])) {
                l()
            } else {
                if (u(h, H) || w === "NEWLINE") {
                    if (n === "else") {
                        p()
                    } else {
                        if ((g === "grSTART_EXPR" || n === "=" || n === ",") && h === "function") {} else {
                            if (n === "return" || n === "throw") {
                                p()
                            } else {
                                if (g !== "grEND_EXPR") {
                                    if ((g !== "grSTART_EXPR" || h !== "var") && n !== ":") {
                                        if (h === "if" && C === "else" && n !== "{") {
                                            p()
                                        } else {
                                            l()
                                        }
                                    }
                                } else {
                                    if (u(h, H) && n !== ")") {
                                        l()
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (w === "SPACE") {
                        p()
                    }
                }
            }
            o();
            C = h;
            if (h === "var") {
                i.var_line = true;
                i.var_line_tainted = false
            }
            if (h === "if" || h === "else") {
                i.if_line = true
            }
            break;
        case "grSEMICOLON":
            o();
            i.var_line = false;
            break;
        case "grSTRING":
            if (g === "grSTART_BLOCK" || g === "grEND_BLOCK" || g === "grSEMICOLON") {
                l()
            } else {
                if (g === "grWORD") {
                    p()
                }
            }
            o();
            break;
        case "grOPERATOR":
            var x = true;
            var B = true;
            if (i.var_line && h === "," && (W(i.mode))) {
                i.var_line_tainted = false
            }
            if (i.var_line) {
                if (h === ",") {
                    if (i.var_line_tainted) {
                        o();
                        l();
                        j.push(D);
                        i.var_line_tainted = false;
                        break
                    } else {
                        i.var_line_tainted = false
                    }
                } else {
                    i.var_line_tainted = true;
                    if (h === ":") {
                        i.var_line = false
                    }
                }
            }
            if (n === "return" || n === "throw") {
                p();
                o();
                break
            }
            if (h === ":" && i.in_case) {
                o();
                l();
                i.in_case = false;
                break
            }
            if (h === "::") {
                o();
                break
            }
            if (h === ",") {
                if (i.var_line) {
                    if (i.var_line_tainted) {
                        o();
                        l();
                        i.var_line_tainted = false
                    } else {
                        o();
                        p()
                    }
                } else {
                    if (g === "grEND_BLOCK") {
                        o();
                        l()
                    } else {
                        if (i.mode === "BLOCK") {
                            o();
                            l()
                        } else {
                            o();
                            p()
                        }
                    }
                }
                break
            } else {
                if (h === "--" || h === "++") {
                    if (n === ";") {
                        if (i.mode === "BLOCK") {
                            l();
                            x = true;
                            B = false
                        } else {
                            x = true;
                            B = false
                        }
                    } else {
                        if (n === "{") {
                            l()
                        }
                        x = false;
                        B = false
                    }
                } else {
                    if ((h === "!" || h === "+" || h === "-") && (n === "return" || n === "case")) {
                        x = true;
                        B = false
                    } else {
                        if ((h === "!" || h === "+" || h === "-") && g === "grSTART_EXPR") {
                            x = false;
                            B = false
                        } else {
                            if (g === "grOPERATOR") {
                                x = false;
                                B = false
                            } else {
                                if (g === "grEND_EXPR") {
                                    x = true;
                                    B = true
                                } else {
                                    if (h === ".") {
                                        x = false;
                                        B = false
                                    } else {
                                        if (h === ":") {
                                            if (bf()) {
                                                x = true
                                            } else {
                                                x = false
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (x) {
                p()
            }
            o();
            if (B) {
                p()
            }
            break;
        case "grBLOCK_COMMENT":
            l();
            if (h.substring(0, 3) == "/**") {
                be()
            } else {
                o()
            }
            l();
            break;
        case "grCOMMENT":
            p();
            o();
            l();
            break;
        case "grUNKNOWN":
            o();
            break
        }
        N = n;
        g = I;
        n = h
    }
    return j.join("").replace(/\n+$/, "")
}
var indent_size = 2;
var indent_char = " ";
var preserve_newlines = true;
var space_after_anon_function = true;

function test_beautifier(b) {
    return JSpercantik(b, {
        indent_size: indent_size,
        indent_char: indent_char,
        preserve_newlines: preserve_newlines,
        space_after_anon_function: space_after_anon_function
    })
}
var sanitytest;

function bt(b, a) {
    var d, f;
    a = a || b;
    sanitytest.expect(b, a);
    if (indent_size === 4 && b) {
        d = "{\n" + b + "\nindent;}";
        f = "{\n" + a.replace(/^(.+)$/mg, "    $1") + "\n    indent;\n}";
        sanitytest.expect(d, f)
    }
}
var JavascriptObfuscator = {
    detect: function (b) {
        return /^var _0x[a-f0-9]+ ?\= ?\[/.test(b)
    },
    unpack: function (b) {
        if (JavascriptObfuscator.detect(b)) {
            var a = /var (_0x[a-f\d]+) ?\= ?\[(.*?)\];/.exec(b);
            if (a) {
                var d = a[1];
                var f = JavascriptObfuscator._0(JavascriptObfuscator._1(a[2]));
                b = b.substring(a[0].length);
                for (var q in f) {
                    b = b.replace(new RegExp(d + "\\[" + q + "\\]", "g"), f[q])
                }
            }
        }
        return b
    },
    _0: function (b) {
        var a = [];
        var d = 0;
        while (d < b.length) {
            if (b.charAt(d) == "\"") {
                var f = "";
                d += 1;
                while (d < b.length) {
                    if (b.charAt(d) == "\"") {
                        break
                    }
                    if (b.charAt(d) == "\\") {
                        f += "\\";
                        d++
                    }
                    f += b.charAt(d);
                    d++
                }
                a.push("\"" + f + "\"")
            }
            d += 1
        }
        return a
    },
    _1: function (b) {
        for (var a = 32; a < 128; a++) {
            b = b.replace(new RegExp("\\\\x" + a.toString(16), "ig"), String.fromCharCode(a))
        }
        return b
    },
    run_tests: function (b) {
        var a = b || new SanityTest();
        a.test_function(JavascriptObfuscator._0, "JavascriptObfuscator._0");
        a.expect("", []);
        a.expect("\"a\", \"b\"", ["\"a\"", "\"b\""]);
        a.expect("\"aaa\",\"bbbb\"", ["\"aaa\"", "\"bbbb\""]);
        a.expect("\"a\", \"b\\\"\"", ["\"a\"", "\"b\\\"\""]);
        a.test_function(JavascriptObfuscator._1, "JavascriptObfuscator._1");
        a.expect("\\x40", "@");
        a.expect("\\x10", "\\x10");
        a.expect("\\x1", "\\x1");
        a.test_function(JavascriptObfuscator.detect, "JavascriptObfuscator.detect");
        a.expect("", false);
        a.expect("abcd", false);
        a.expect("var _2", false);
        a.expect("var _2 = [\"a\", \"b\"]", true);
        a.expect("var _2=[\"a\", \"b\"]", true);
        a.expect("var _3=[\"a\",\"b\"]", true);
        return a
    }
};

function style_html(t, y, z, Q) {
    var v, c;

    function v() {
        this.pos = 0;
        this.token = "";
        this.current_mode = "inout";
        this.tags = {
            parent: "parent1",
            parentcount: 1,
            parent1: ""
        };
        this.tag_type = "";
        this.token_text = this.last_token = this.last_text = this.token_type = "";
        this.Utils = {
            whitespace: "\n\r\t ".split(""),
            single_token: "br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed".split(","),
            extra_liners: "head,body,/html".split(","),
            in_array: function (b, a) {
                for (var d = 0; d < a.length; d++) {
                    if (b === a[d]) {
                        return true
                    }
                }
                return false
            }
        };
        this.get_inout = function () {
            var b = "";
            var a = [];
            var d = false;
            while (this.input.charAt(this.pos) !== "<") {
                if (this.pos >= this.input.length) {
                    return a.length ? a.join("") : ["", "grEOF"]
                }
                b = this.input.charAt(this.pos);
                this.pos++;
                this.line_char_count++;
                if (this.Utils.in_array(b, this.Utils.whitespace)) {
                    if (a.length) {
                        d = true
                    }
                    this.line_char_count--;
                    continue
                } else {
                    if (d) {
                        if (this.line_char_count >= this.max_char) {
                            a.push("\n");
                            for (var f = 0; f < this.indent_level; f++) {
                                a.push(this.indent_string)
                            }
                            this.line_char_count = 0
                        } else {
                            a.push(" ");
                            this.line_char_count++
                        }
                        d = false
                    }
                }
                a.push(b)
            }
            return a.length ? a.join("") : ""
        };
        this.get_script = function () {
            var b = "";
            var a = [];
            var d = new RegExp("</script>", "igm");
            d.lastIndex = this.pos;
            var f = d.exec(this.input);
            var q = f ? f.index : this.input.length;
            while (this.pos < q) {
                if (this.pos >= this.input.length) {
                    return a.length ? a.join("") : ["", "grEOF"]
                }
                b = this.input.charAt(this.pos);
                this.pos++;
                a.push(b)
            }
            return a.length ? a.join("") : ""
        };
        this.record_tag = function (b) {
            if (this.tags[b + "count"]) {
                this.tags[b + "count"]++;
                this.tags[b + this.tags[b + "count"]] = this.indent_level
            } else {
                this.tags[b + "count"] = 1;
                this.tags[b + this.tags[b + "count"]] = this.indent_level
            }
            this.tags[b + this.tags[b + "count"] + "parent"] = this.tags.parent;
            this.tags.parent = b + this.tags[b + "count"]
        };
        this.retrieve_tag = function (b) {
            if (this.tags[b + "count"]) {
                var a = this.tags.parent;
                while (a) {
                    if (b + this.tags[b + "count"] === a) {
                        break
                    }
                    a = this.tags[a + "parent"]
                }
                if (a) {
                    this.indent_level = this.tags[b + this.tags[b + "count"]];
                    this.tags.parent = this.tags[a + "parent"]
                }
                delete this.tags[b + this.tags[b + "count"] + "parent"];
                delete this.tags[b + this.tags[b + "count"]];
                if (this.tags[b + "count"] == 1) {
                    delete this.tags[b + "count"]
                } else {
                    this.tags[b + "count"]--
                }
            }
        };
        this.get_tag = function () {
            var b = "";
            var a = [];
            var d = false;
            do {
                if (this.pos >= this.input.length) {
                    return a.length ? a.join("") : ["", "grEOF"]
                }
                b = this.input.charAt(this.pos);
                this.pos++;
                this.line_char_count++;
                if (this.Utils.in_array(b, this.Utils.whitespace)) {
                    d = true;
                    this.line_char_count--;
                    continue
                }
                if (b === "'" || b === "\"") {
                    if (!a[1] || a[1] !== "!") {
                        b += this.get_unformatted(b);
                        d = true
                    }
                }
                if (b === "=") {
                    d = false
                }
                if (a.length && a[a.length - 1] !== "=" && b !== ">" && d) {
                    if (this.line_char_count >= this.max_char) {
                        this.print_newline(false, a);
                        this.line_char_count = 0
                    } else {
                        a.push(" ");
                        this.line_char_count++
                    }
                    d = false
                }
                a.push(b)
            } while (b !== ">");
            var f = a.join("");
            var q;
            if (f.indexOf(" ") != -1) {
                q = f.indexOf(" ")
            } else {
                q = f.indexOf(">")
            }
            var m = f.substring(1, q).toLowerCase();
            if (f.charAt(f.length - 2) === "/" || this.Utils.in_array(m, this.Utils.single_token)) {
                this.tag_type = "SINGLE"
            } else {
                if (m === "script") {
                    this.record_tag(m);
                    this.tag_type = "SCRIPT"
                } else {
                    if (m === "style") {
                        this.record_tag(m);
                        this.tag_type = "STYLE"
                    } else {
                        if (m.charAt(0) === "!") {
                            if (m.indexOf("[if") != -1) {
                                if (f.indexOf("!IE") != -1) {
                                    var r = this.get_unformatted("-->", f);
                                    a.push(r)
                                }
                                this.tag_type = "START"
                            } else {
                                if (m.indexOf("[endif") != -1) {
                                    this.tag_type = "END";
                                    this.unindent()
                                } else {
                                    if (m.indexOf("[cdata[") != -1) {
                                        var r = this.get_unformatted("]]>", f);
                                        a.push(r);
                                        this.tag_type = "SINGLE"
                                    } else {
                                        var r = this.get_unformatted("-->", f);
                                        a.push(r);
                                        this.tag_type = "SINGLE"
                                    }
                                }
                            }
                        } else {
                            if (m.charAt(0) === "/") {
                                this.retrieve_tag(m.substring(1));
                                this.tag_type = "END"
                            } else {
                                this.record_tag(m);
                                this.tag_type = "START"
                            }
                            if (this.Utils.in_array(m, this.Utils.extra_liners)) {
                                this.print_newline(true, this.output)
                            }
                        }
                    }
                }
            }
            return a.join("")
        };
        this.get_unformatted = function (b, a) {
            if (a && a.indexOf(b) != -1) {
                return ""
            }
            var d = "";
            var f = "";
            var q = true;
            do {
                d = this.input.charAt(this.pos);
                this.pos++;
                if (this.Utils.in_array(d, this.Utils.whitespace)) {
                    if (!q) {
                        this.line_char_count--;
                        continue
                    }
                    if (d === "\n" || d === "\r") {
                        f += "\n";
                        for (var m = 0; m < this.indent_level; m++) {
                            f += this.indent_string
                        }
                        q = false;
                        this.line_char_count = 0;
                        continue
                    }
                }
                f += d;
                this.line_char_count++;
                q = true
            } while (f.indexOf(b) == -1);
            return f
        };
        this.get_token = function () {
            var b;
            if (this.last_token === "grTAG_SCRIPT") {
                var a = this.get_script();
                if (typeof a !== "string") {
                    return a
                }
                b = JSpercantik(a, {
                    indent_size: this.indent_size,
                    indent_char: this.indent_character,
                    indent_level: this.indent_level
                });
                return [b, "grinout"]
            }
            if (this.current_mode === "inout") {
                b = this.get_inout();
                if (typeof b !== "string") {
                    return b
                } else {
                    return [b, "grinout"]
                }
            }
            if (this.current_mode === "TAG") {
                b = this.get_tag();
                if (typeof b !== "string") {
                    return b
                } else {
                    var d = "grTAG_" + this.tag_type;
                    return [b, d]
                }
            }
        };
        this.printer = function (f, q, m, r) {
            this.input = f || "";
            this.output = [];
            this.indent_character = q || " ";
            this.indent_string = "";
            this.indent_size = m || 2;
            this.indent_level = 0;
            this.max_char = r || 70;
            this.line_char_count = 0;
            for (var s = 0; s < this.indent_size; s++) {
                this.indent_string += this.indent_character
            }
            this.print_newline = function (b, a) {
                this.line_char_count = 0;
                if (!a || !a.length) {
                    return
                }
                if (!b) {
                    while (this.Utils.in_array(a[a.length - 1], this.Utils.whitespace)) {
                        a.pop()
                    }
                }
                a.push("\n");
                for (var d = 0; d < this.indent_level; d++) {
                    a.push(this.indent_string)
                }
            };
            this.print_token = function (b) {
                this.output.push(b)
            };
            this.indent = function () {
                this.indent_level++
            };
            this.unindent = function () {
                if (this.indent_level > 0) {
                    this.indent_level--
                }
            }
        };
        return this
    }
    c = new v();
    c.printer(t, z, y);
    while (true) {
        var j = c.get_token();
        c.token_text = j[0];
        c.token_type = j[1];
        if (c.token_type === "grEOF") {
            break
        }
        switch (c.token_type) {
        case "grTAG_START":
        case "grTAG_SCRIPT":
        case "grTAG_STYLE":
            c.print_newline(false, c.output);
            c.print_token(c.token_text);
            c.indent();
            c.current_mode = "inout";
            break;
        case "grTAG_END":
            c.print_newline(true, c.output);
            c.print_token(c.token_text);
            c.current_mode = "inout";
            break;
        case "grTAG_SINGLE":
            c.print_newline(false, c.output);
            c.print_token(c.token_text);
            c.current_mode = "inout";
            break;
        case "grinout":
            if (c.token_text !== "") {
                c.print_newline(false, c.output);
                c.print_token(c.token_text)
            }
            c.current_mode = "TAG";
            break
        }
        c.last_token = c.token_type;
        c.last_text = c.token_text
    }
    return c.output.join("")
}